<!-- 积分余额 -->
<template>
	<view class="page_box">
		<view class="head_box padding">
			<cu-custom :isBack="true">
				<block slot="backText">积分余额</block>
				<block slot="content"></block>
			</cu-custom>
			<image class="bg" :src="$IMG_URL + '/imgs/user/integral_bg.png'" mode=""></image>
			<view class="all-box x-c">
				<text class="all-num">{{ score }}</text>
				<text class="all-title">当前积分</text>
			</view>
			
		</view>
		<shopro-modal v-model="showModal" style="z-index: 88;">
			<block slot="modalContent">
				<view class="modal-box padding-top">
					<view class="modal-head">
						
						<text class="modal-head-title">生成优惠券</text>
					</view>
					<input class="inp" type="number"  v-model="amount" placeholder="在此输入金额" placeholder-class="pl-inp" />
					<button class="cu-btn post-btn" @tap="getScoreLog1">生成</button>
				</view>
			</block>
		</shopro-modal>
		<view class="content_box">
			<view class="resale-list x-bc" @tap="showModal = true">
				<view class="x-f">
					<text class=" cuicon cuIcon-vipcard"></text>
					<text>生成优惠券</text>
				</view>
				<text class="cuIcon-right"></text>
			</view>
			<view class="resale-list x-bc" @tap="jump('pages/user/wallet/log' , {wallet_type : 'send_score'})">
				<view class="x-f">
					<text class=" cuicon cuIcon-vipcard"></text>
					<text>积分记录</text>
				</view>
				<text class="cuIcon-right"></text>
			</view>
			
			<!-- <view class="resale-list x-bc" @tap="jump('/pages/user/team/index')">
				<view class="x-f">
					<text class=" cuicon cuIcon-friend"></text>
					<text>我的团队</text>
				</view>
				<text class="cuIcon-right"></text>
			</view> -->
			<!-- <view class="resale-list x-bc" @tap="jump('/pages/user/poster')">
				<view class="x-f">
					<text class=" cuicon cuIcon-present"></text>
					<text>邀请好友</text>
				</view>
				<text class="cuIcon-right"></text>
			</view> -->
		</view>
		<view class="foot_box"></view>
		<!-- 自定义底部导航 -->
		<shopro-tabbar></shopro-tabbar>
		<!-- 关注弹窗 -->
		<shopro-float-btn></shopro-float-btn>
		<!-- 连续弹窗提醒 -->
		<shopro-notice-modal></shopro-notice-modal>
	</view>
</template>

<script>
import { mapMutations, mapActions, mapState } from 'vuex';
export default {
	components: {},
	data() {
		return {
			tabDot: 'all',
			scoreLog: [],
			timestamp: this.$tools.timestamp,
			loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
			currentPage: 1,
			lastPage: 1,
			showModal:false,
			amount:''
		};
	},
	computed: {
		...mapState({
			score: state => state.user.userInfo.score
		})
	},
	onLoad() {
		
	},
	methods: {
		getScoreLog1(type) {
			if (!this.amount) return this.$tools.toast('请输入金额');
			let that = this;
			that.loadStatus = 'loading';
			that.$api('generateCoupons', {
				amount:this.amount
				
			}).then(res => {
				this.amount=''
				if (res.code) {
					 this.$tools.toast('充值成功')
					 
				}
			});
		},
		
		jump(path, parmas) {
			this.$Router.push({
				path: path,
				query: parmas
			});
		},
		
		
		
		
		
		
		loadMore() {
			if (this.currentPage < this.lastPage) {
				this.currentPage += 1;
				this.getScoreLog();
			}
		},
		onTab(type) {
			this.tabDot = type;
			this.scoreLog = [];
			this.currentPage = 1;
			this.$u.debounce(this.getScoreLog);
		},
		// 积分明细
		getScoreLog(type) {
			
			
			
			let that = this;
			that.loadStatus = 'loading';
			that.$api('user_wallet_log', {
				wallet_type: 'score ',
				status: that.tabDot,
				page: that.currentPage
			}).then(res => {
				if (res.code === 1) {
					that.scoreLog = [...that.scoreLog, ...res.data.data];
					that.lastPage = res.data.last_page;
					if (that.currentPage < res.data.last_page) {
						that.loadStatus = 'loadmore';
					} else {
						that.loadStatus = 'nomore';
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
	.modal-box {
		background: #fff;
		width: 610rpx;
		margin: 0 auto;
		border-radius: 20rpx;
		.modal-head-img {
			width: 100%;
			height: 213rpx;
		}
	
		.modal-head-title {
			font-size: 35rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #6d5028;
			line-height: 42rpx;
		}
	
		.inp {
			width: 501rpx;
			height: 78rpx;
			border: 1rpx solid rgba(168, 112, 13, 1);
			margin: 60rpx auto 40rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #6d5028;
	
			.pl-inp {
				color: #bd9560;
			}
		}
	
		.radio {
			width: 500rpx;
			padding: 0 50rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: rgba(200, 150, 61, 1);
			margin-bottom: 20rpx;
	
			.radio-inp {
				transform: scale(0.7);
				margin-right: 10rpx;
			}
		}
	
		.post-btn {
			width: 492rpx;
			height: 70rpx;
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
			box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
			border-radius: 35rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: rgba(255, 255, 255, 1);
			padding: 0;
			margin-bottom: 60rpx;
		}
	}
	
	.head_box {
		width: 750rpx;
		height: 480rpx;
		background: linear-gradient(125deg, rgba(239, 196, 128, 1) 0%, rgba(248, 220, 165, 1) 100%);
		position: relative;
	
		.resale-bg {
			width: 750rpx;
			height: 64rpx;
			position: absolute;
			bottom: 0;
		}
	
		.card-box {
			width: 695rpx;
			height: 298rpx;
			padding: 40rpx;
			background: url($IMG_URL+'/imgs/money_wallet_bg.png') no-repeat;
			background-size: 100% 100%;
			box-shadow: 0px 0px 12rpx 9rpx rgba(#f8dca5, 0.82);
			border-radius: 30rpx;
			overflow: hidden;
			position: absolute;
			left: 50%;
			transform: translateX(-50%);
			bottom: 30rpx;
			z-index: 6;
	
			.left {
				display: flex;
				justify-content: space-between;
				height: 100%;
			}
	
			.cash-btn {
				width: 170rpx;
				height: 64rpx;
				background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
				border: 2rpx solid rgba(230, 184, 115, 1);
				box-shadow: 0px 7px 6px 0px rgba(229, 138, 0, 0.22);
				border-radius: 32rpx;
				padding: 0;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(51, 51, 51, 1);
			}
	
			.title {
				font-size: 30rpx;
				font-family: Noto Sans S Chinese;
				font-weight: 400;
				color: rgba(230, 184, 115, 1);
				line-height: 30rpx;
			}
	
			.money-num {
				font-size: 70rpx;
				font-family: FZHei-B01S;
				font-weight: 400;
				color: rgba(230, 184, 115, 1);
				line-height: 72rpx;
			}
	
			.add {
				font-size: 22rpx;
				width: 400rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: rgba(230, 184, 115, 1);
				line-height: 26rpx;
			}
		}
	}
	
	.resale-list {
		height: 96rpx;
		background: #fff;
		padding: 0 30rpx 0 40rpx;
		border-bottom: 1rpx solid #dfdfdf;
		font-size: 28rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	
		.cuicon {
			font-size: 40rpx;
			color: #666;
			margin-right: 30rpx;
		}
	}
.scroll-box {
	flex: 1;
	height: 100%;
	padding: 0 30rpx;
}
.page_box {
	background: #fff;
	.head_box {
		width: 750rpx;
		height: 480rpx;
		background: linear-gradient(180deg, rgba(239, 196, 128, 1) 0%, rgba(248, 220, 165, 1) 56.99999999999999%, rgba(255, 255, 255, 1) 100%);
		position: relative;
		.bg {
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			width: 310rpx;
			height: 310rpx;
		}
		.all-box {
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			width: 180rpx;
			height: 180rpx;
			.all-num {
				font-size: 50rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #a8700d;
				margin-bottom: 20rpx;
			}
			.all-title {
				position: absolute;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(168, 112, 13, 1);
				line-height: 54rpx;
				text-align: center;
				width: 154rpx;
				height: 53rpx;
				background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
				border-radius: 27rpx;
				bottom: -16rpx;
			}
		}
		.tab-box {
			position: absolute;
			left: 50%;
			bottom: 0;
			transform: translateX(-50%);
			width: 710rpx;
			height: 90rpx;
			background: rgba(255, 255, 255, 1);
			border-radius: 30rpx 30rpx 0px 0px;
			border-bottom: 1rpx solid #dfdfdf;
			padding: 0 30rpx;
			.tab-item {
				flex: 1;
				.tab-name {
					font-size: 30rpx;
					font-family: Noto Sans S Chinese;
					font-weight: 400;
					color: rgba(51, 51, 51, 1);
					border-bottom: 4rpx solid transparent;
					line-height: 86rpx;
				}
				.tab-active {
					border-bottom: 4rpx solid rgba(213, 166, 90, 1);
				}
			}
		}
	}
}
.item-box {
	background: #fff;
	min-height: 150rpx;
	border-bottom: 1rpx solid #dfdfdf;
	padding: 30rpx;
	.name {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(102, 102, 102, 1);
		line-height: 28rpx;
		margin-bottom: 20rpx;
	}
	.time {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(196, 196, 196, 1);
		line-height: 24px;
	}
	.num {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #e6b873;
	}
}
</style>
